package com.yurun.controller.admin;

import com.yurun.entity.LoginLog;
import com.yurun.model.vo.Result;
import com.yurun.service.LoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/admin")
public class LoginLogController {
    @Autowired
    LoginLogService loginLogService;
    /**
     * @Description: 添加登录日志
     * @Param: loginLog 
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @PostMapping("/loginlog")
    public Result addLoginLog(@RequestBody LoginLog loginLog){
        loginLogService.addLoginLog(loginLog);
        return Result.ok("添加登录日志成功");
    }
    /**
     * @Description: 通过ID-删除登录日志
     * @Param: id
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @DeleteMapping("/loginlog/id")
    public Result deleteLoginLogById(@RequestParam Long id){
        loginLogService.deleteLoginLogById(id);
        return Result.ok("删除登录日志成功");
    }
    /**
     * @Description: 通过日期-获取登录日志列表
     * @Param: startDate
	 * @Param: endDate
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("loginlog/date")
    public Result getLoginLogListByDate(@RequestParam String startDate,
                                        @RequestParam String endDate){
        List<LoginLog> object=loginLogService.getLoginLogListByDate(startDate, endDate);
        return Result.ok("登录日志查询成功",object);
    }
}
